package com.weather.service;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class InsertSql {
	//private static Logger log = Logger.getLogger("addUserServlet.class");  
	public static int insertable(String sql) throws Exception{
	
	int ispassword =0;
	PreparedStatement pre = null;
	try{
		Connection coon = Dbunit.getConn();
		pre=coon.prepareStatement(sql);
		//pre.execute();
		ispassword=pre.executeUpdate();	
		
	} catch (Exception e) {
		//e.printStackTrace();
		//log.info(e.getMessage());
		String mess=e.getMessage().substring(e.getMessage().toString().length()-8);
		String[] message = mess.split("'");
		if (message[0].endsWith("PRIMARY")){
			ispassword=5000;
		}else{
			e.printStackTrace();
		}
	}finally{
		try {			
			pre.close();			
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	return ispassword;
	}

}
